﻿//  -------------------- iSharePoint -------------------- //
// 
//  Company:	IT Complex, LLC
//  Project:	Smart.Common
//  File name:	ClientAssetRegistration.cs
//  Developer:	Solomatov Igor
//  Created:	14.04.2012
// 
//  -------------------- iSharePoint -------------------- //

using System;
using System.ComponentModel;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Smart.Common.WebControls
{
	[ToolboxData("<{0}:ClientAssetRegistration runat=server></{0}:ClientAssetRegistration>")]
	public class ClientAssetRegistration : WebControl
	{
		[Bindable(true)]
		[Category("Appearance")]
		[DefaultValue("")]
		[Localizable(true)]
		public string Key
		{
			get { return (string) ViewState["Key"] ?? string.Empty; }
			set { ViewState["Key"] = value; }
		}

		[Bindable(true)]
		[Category("Appearance")]
		[DefaultValue("")]
		[Localizable(true)]
		public string Param
		{
			get { return (string) ViewState["Param"] ?? string.Empty; }
			set { ViewState["Param"] = value; }
		}

		protected override void OnPreRender(EventArgs e)
		{
			if (!string.IsNullOrEmpty(Key))
				ClientAssets.Register(Key, Param);

			base.OnPreRender(e);
		}
	}
}